'24310-80
'GCV_EXTENDED = 7
'SIDE = GCV_FRONT

'DETAIL_LEVEL =GCV_EXTENDED

hatchAngle  = 45                  
hatchStep=0.5        
drawFace1=1
'PAR_AXIS = 1

'PAR_din=18
'PAR_d=22
'PAR_b=13
'PAR_bottomSide =1


PAR1_r=0.01

'++++
SUB LINE (x1,y1,x2,y2,t) Doc.ksLineSEG x1,y1,x2,y2,t END SUB
'++++
SUB DrawRoller (rn,rv,ytr,b,ky,del)
If PAR_AXIS = 1 Then 
If PAR_bottomSide =1 Then 
Line 0,0,0,(rv+ytr)*0.5*ky,1
End If 
End If 
 If PAR_AXIS = 1 Then 
   Line b,0,b,(rv+ytr)*0.5*ky,1
 End If 

  Line  b*0.2,rv*ky,B*0.2,rn*ky, 1
  Line  b*0.2,rn*ky,b*0.8,rn*ky, 1 
  Line  b*0.8,rn*ky,b*0.8,rv*ky, 1 
  Line  b*0.2,rv*ky,b*0.8,rv*ky, 1 

 Line 0,(rv+ytr)*0.5*ky,0.15*b,(rv+ytr)*0.5*ky,1
 Line 0,(rn+ytr)*0.5*ky,0.15*b,(rn+ytr)*0.5*ky,1
If PAR_bottomSide =1 then
Line 0,(rn+ytr)*0.5*ky,0,(rv+ytr)*0.5*ky,1
End if

  Line 0.2*b,rn*ky,0.15*b,(rn+ytr)*0.5*ky,1
  Line 0.2*b,rv*ky,0.15*b,(rv+ytr)*0.5*ky,1

Line 0.1*b,(rn+ytr)*0.5*ky, 0.1*b, (rv+ytr)*0.5*ky,1
Line 0.15*b,(rn+ytr)*0.5*ky,0.15*b,(rv+ytr)*0.5*ky,1

Line 0.8*b,rn*ky,0.85*b,(rn+ytr)*0.5*ky,1
Line 0.8*b,rv*ky,0.85*b,(rv+ytr)*0.5*ky,1

 Line b*0.85,(rv+ytr)*0.5*ky,b,(rv+ytr)*0.5*ky,1
 Line b*0.85,(rn+ytr)*0.5*ky,b,(rn+ytr)*0.5*ky,1

 Line b,(rn+ytr)*0.5*ky,b,(rv+ytr)*0.5*ky,1

Line 0.9*b,(rn+ytr)*0.5*ky, 0.9*b, (rv+ytr)*0.5*ky,1
Line 0.85*b,(rn+ytr)*0.5*ky,0.85*b,(rv+ytr)*0.5*ky,1


Doc.kshatch  0, hatchAngle, hatchStep, 0, 0, 0
 Line 0,(rv+ytr)*0.5*ky,0.1*b,(rv+ytr)*0.5*ky,1
 Line 0,(rn+ytr)*0.5*ky,0.1*b,(rn+ytr)*0.5*ky,1
 Line 0,(rn+ytr)*0.5*ky,0,(rv+ytr)*0.5*ky,1
 Line 0.1*b,(rn+ytr)*0.5*ky, 0.1*b, (rv+ytr)*0.5*ky,1
Doc.ksEndObj

Doc.kshatch  0, hatchAngle, hatchStep, 0, 0, 0
 Line 0.9*b,(rn+ytr)*0.5*ky, 0.9*b, (rv+ytr)*0.5*ky,1
 Line b,(rn+ytr)*0.5*ky,b,(rv+ytr)*0.5*ky,1
 Line b*0.9,(rv+ytr)*0.5*ky,b,(rv+ytr)*0.5*ky,1
 Line b*0.9,(rn+ytr)*0.5*ky,b,(rn+ytr)*0.5*ky,1

Doc.ksEndObj

Line -del,ytr*ky,b+del,ytr*ky,3

If PAR_AXIS = 1 Then 
IF  ky = 1 and DETAIL_LEVEL <> GCV_STANDARD  THEN 
   Line  -2, 0, b+2, 0, 3 
 End If
End If   
END SUB
'++++++++++
Sub DrawSimple (rv, rn, rf1, rf2,rf3, rf4, b,  ky) 

 x1=rf1
 x2=rf2
 x3=b-rf3
 x4=b-rf4

 y1=(rv+rf1)*ky
 y2=(rn-rf2)*ky
 y3=(rn-rf3)*ky
 y4=(rv+rf4)*ky

  if  drawFace1=1 then
    line 0,y1,0,y2,1
end if

  doc.ksArcByPoint x2,y2,rf2,0,y2,x2,rn*ky,-ky,1 ';  /*5*/
  line x2,rn*ky,x3,rn*ky,1
  doc.ksArcByPoint x3,y3,rf3,x3,rn*ky,b,y3,-ky,1 ' ; /*6*/
  line b,y3,b,y4,1
doc.ksArcByPoint x4,y4,rf4,b,y4,x4,rv*ky,-ky,1 '; /*7*/
  line x4,rv*ky,x1,rv*ky,1
  doc.ksArcByPoint x1,y1,rf1,x1,rv*ky,0,y1,-ky,1 ';     /*8*/

 If PAR_Simpl_AXIS = 1 Then 
  Line x1,y1,x3,y3,2
  Line x2,y2,x4,y4,2
  Else 
  ''new 
  dxy = (rn-rv)/6
  Line b*0.5-dxy,(rn+rv)*0.5*ky,b*0.5+dxy,(rn+rv)*0.5*ky,2
  Line b*0.5,((rn+rv)*0.5-dxy)*ky,b*0.5,((rn+rv)*0.5+dxy)*ky,2
End If 
  if PAR_AXIS = 1 THEN  
    line b,0,b,y4,1
    line x1,0,x1,rv*ky,1

    if  drawFace1 =1 then
'      line 0,y1,0,0,1
   end if
     if ky = 1  then
      line -2, 0, b+2, 0, 3
end if
  end if
end sub
'+++++++++++++++
Sub Script_OnLoad ()

rn=PAR_D*0.5
rv=PAR_din*0.5
xs=Par_b*0.5
ys=(Par_D+Par_din)*0.25

doc.ksColouring &HFE000000

IF PAR_bottomSide =1 THEN
If DETAIL_LEVEL = GCV_SIMPLIFIED Then 
	tip = 0 
Else 
  tip = 1 
End If  	
contur rn,rv,ys,xs*2,1,tip
If DETAIL_LEVEL = GCV_SIMPLIFIED or DETAIL_LEVEL = GCV_STANDARD Then 
	tip = 0 
Else 
  tip = 1 
End If  
contur rn,rv,ys,xs*2,-1,tip
Else 
If DETAIL_LEVEL = GCV_SIMPLIFIED Then 
	tip = 0 
Else 
  tip = 1 
End If  	
 contur rn,rv,ys,xs,1,tip
If DETAIL_LEVEL = GCV_SIMPLIFIED or DETAIL_LEVEL = GCV_STANDARD Then 
	tip = 0 
Else 
  tip = 1 
End If
 contur rn,rv,ys,xs,-1,tip

 Doc.ksMtr xs,0,0,1,1
 If DETAIL_LEVEL = GCV_SIMPLIFIED Then 
	tip = 0 
Else 
  tip = 1 
End If 
 contur rn,rv,ys,xs,1,tip
 If DETAIL_LEVEL = GCV_SIMPLIFIED or DETAIL_LEVEL = GCV_STANDARD Then 
	tip = 0 
Else 
  tip = 1 
End If
 contur rn,rv,ys,xs,-1,tip
 Doc.KsDeleteMtr 
End If 
doc.ksEndObj


SELECT CASE DETAIL_LEVEL
      Case GCV_EXTENDED:

IF PAR_bottomSide =1 THEN
 DrawRoller rn,rv,ys,xs*2,1,2
 DrawRoller rn,rv,ys,xs*2,-1,2
else
Doc.ksMtr xs, 0,180, 1 ,1
 DrawRoller rn,rv,ys,xs,1,2
 DrawRoller rn,rv,ys,xs,-1,2
Doc.KsDeleteMtr 

 Doc.ksMtr xs, 0,0, 1 ,1
 DrawRoller rn,rv,ys,xs,1,2
 DrawRoller rn,rv,ys,xs,-1,2
Doc.KsDeleteMtr 

end if


case  GCV_STANDARD:

IF PAR_bottomSide =1 THEN
 
 if PAR_AXIS = 1 THEN
 Line  -2, 0,PAR_b+2, 0, 3 
End If 
 DrawRoller rn,rv,ys,xs*2,1,2
 DrawSimple rv, rn,  PAR1_r,  PAR1_r,  PAR1_r,  PAR1_r, PAR_B, -1 

else
 Doc.ksMtr PAR_B/2, 0,0, 1 ,1
 DrawRoller rn,rv,ys,xs,1,2
'''''' DrawSimple rv, rn,  PAR1_r,  PAR1_r,  PAR1_r,  PAR1_r, PAR_B, -1 

 Doc.ksMtr 0, 0,180, 1 ,1

 DrawRoller rn,rv,ys,xs,-1,2
 Doc.KsDeleteMtr 

 Doc.ksMtr -PAR_B/2, 0,0, 1 ,1
 if PAR_AXIS = 1 THEN
  line -2, 0, PAR_B+2, 0, 3
 End If  
 DrawSimple rv, rn,  PAR1_r,  PAR1_r,  PAR1_r,  PAR1_r, PAR_B, -1 
 Doc.KsDeleteMtr 
 Doc.KsDeleteMtr 

end if
Case GCV_SIMPLIFIED:

DrawSimple rv, rn,  PAR1_r,  PAR1_r,  PAR1_r,  PAR1_r, PAR_B, 1 
DrawSimple rv, rn,  PAR1_r,  PAR1_r,  PAR1_r,  PAR1_r, PAR_B, -1


  END SELECT

END SUB
'+++
Sub Contur (rn,rv,ytr,b,ky,tip)'tip {ext or simpl}= [1/0]
If tip Then 
Line 0,0,0,(rv+ytr)*0.5*ky,1
Line b,0,b,(rv+ytr)*0.5*ky,1
Line 0,0,b,0,1 

 Line  b*0.2,rn*ky,b*0.8,rn*ky, 1 
' Line  b*0.2,rv*ky,b*0.8,rv*ky, 1 
' Line 0,(rv+ytr)*0.5*ky,0.15*b,(rv+ytr)*0.5*ky,1
 Line 0,(rn+ytr)*0.5*ky,0.15*b,(rn+ytr)*0.5*ky,1
 Line 0,(rn+ytr)*0.5*ky,0,(rv+ytr)*0.5*ky,1
 Line 0.2*b,rn*ky,0.15*b,(rn+ytr)*0.5*ky,1
' Line 0.2*b,rv*ky,0.15*b,(rv+ytr)*0.5*ky,1
 Line 0.8*b,rn*ky,0.85*b,(rn+ytr)*0.5*ky,1
 'Line 0.8*b,rv*ky,0.85*b,(rv+ytr)*0.5*ky,1
 'Line b*0.85,(rv+ytr)*0.5*ky,b,(rv+ytr)*0.5*ky,1
 Line b*0.85,(rn+ytr)*0.5*ky,b,(rn+ytr)*0.5*ky,1
 Line b,(rn+ytr)*0.5*ky,b,(rv+ytr)*0.5*ky,1
Else 
Line 0,0,0,rn*ky,1
Line b,0,b,rn*ky,1
Line 0,0,b,0,1
Line 0,rn*ky,b,rn*ky,1
End If  
 
End Sub 



